Method of writing of writing to a flash memory including data blocks and log blocks, using a logical address having a block address portion and page identifying portion, a block address table and a page table

ABSTRACT

A flash memory management method is provided. According to the method, when a request to write the predetermined data to a page to which data has been written is made, the predetermined data is written to a log block corresponding to a data block containing the page. When a request to write the predetermined data to the page again is received, the predetermined data is written to an empty free page in the log block. Even if the same page is requested to be continuously written to, the management method allows this to be processed in one log block, thereby improving the effectiveness in the use of flash memory resources.

This application is a divisional reissue application of U.S. Pat. No.6,938,116, issued on Aug. 30, 2005, and filed on Dec. 31, 2001 as U.S.patent application Ser. No. 10/029,966. Notice: More than one reissueapplication has been filed for the reissue of U.S. Pat. No. 6,938,116.The reissue applications are application Ser. No. 11/848,005, filed onAug. 30, 2007 (issued as U.S. Pat. No. Re. 44,052 on Mar. 5, 2013),application Ser. No. 13/134,225 filed Jun. 2, 2011 (the presentdivisional reissue application of which the Ser. No. 11/848,005application is the parent); and application Ser. No. 13/151,735 filedJun. 2, 2011 (a divisional reissue application filed concurrentlyherewith and also of which the Ser. No. 11/848,005 application is theparent).

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a flash memory, and more particularly,to a flash memory management method for use in a flash memory-basedsystem. The present application is based on Korean Patent ApplicationNo. 2001-31124 filed Jun. 4, 2001.

2. Description of the Related Art

Flash memories are a special type of a nonvolatile memory capable ofelectrically erasing and programming data. Flash memory based storagedevices have low power consumption and small size compared to magneticdisc memory based devices. Thus, since flash memories can be substitutedfor magnetic disk memories, much research and development is actively inprogress. Flash memories are expected to receive considerable attentionas storage devices for mobile computing devices such as digital cameras,mobile phones, or personal digital assistants (PDAs).

In magnetic disc drives, new data can be written over previous old data.However, in flash memories, a block needs to be erased before it isrewritten with new data; that is, memory cells are returned to anoriginal state in which data can be written. This operation is called“erase”. An erase operation typically requires much more time than awrite operation. Furthermore, since the erase operation is performed inblocks whose size is much larger than what the write operation requires,even a portion requested not to be written to may be erased. In thiscase, the unnecessarily erased portion needs to be reclaimed through awrite operation. In the worst scenario, a request to write (overwrite)data requires one erase operation and write operations to recover theportion erased by the erase operation. Due to inconsistency betweenunits on which erase and write commands are executed, write performanceis significantly lower than read performance. Furthermore, the writeperformance of a flash memory is lower than that of a magnetic discbased storage device that inevitably involves a delay due to mechanicaloperation. Thus, improving write performance is essential in designing aflash memory based device.

U.S. Pat. No. 5,388,083 proposes a content addressable memory (CAM)system for converting a logical address requested by a user to aphysical address in a flash memory while avoiding an erase cycle bywriting altered data into an empty block in order to prevent a delay dueto erase-before-write. However, implementation of the CAM systemrequires additional costly circuits. U.S. Pat. No. 5,485,595 proposes anapproach which involves writing a logical address into an extra regionof each page and sequentially comparing each of the logical addresseswhile avoiding an erase cycle by writing altered data into an emptyspace upon a write request. However, if a unit of read operation islarge like in a NAND-type flash memory, the address conversion mechanismrequires a large amount of time in reading address conversioninformation scattered around the flash memory, thereby degrading systemperformance.

U.S. Pat. No. 5,845,313 proposes a flash memory storage architecture inwhich a linear address conversion table for performing a direct addressconversion is constructed in a special RAM by scanning a logical addressstored in a flash memory during a system reset. However, a RAM of alarge storage capacity is required to store the address conversiontable. For example, to store an address conversion table of a flashmemory based storage device having a storage capacity of 32 MB and apage size of 512 bytes, 128 KB of RAM is required assuming that 2 bytesare provided for each of 65,536 pages. The storage capacity is too largefor a small-scale system having few resources such as mobile equipment.

U.S. Pat. No. 5,404,485 proposes an approach for allocating a new block(replacement block) for write operation and writing data to theallocated block. However, since a new block continues to be allocatedfor write operation, a plurality of different versions of blocks towhich the same page is written exist. That is, at least one replacementblock needs to be provided for every block, thereby significantlyreducing the capacity of a flash memory. A page to be written to a newblock must be written at the same position as the position at which thepage was written to the previous block. When the page is frequentlyupdated but the remaining pages are rarely updated, only the content ofthe specific page is changed while the remaining pages contain aplurality of the same replacement blocks, thereby wasting a lot ofstorage space in a flash memory. Thus, this approach is not suitable forsmall-scale systems such as mobile equipment.

SUMMARY OF THE INVENTION

To solve the above problems, it is an object of the present invention toprovide a flash memory based system and management method thereforcapable of improving the performance of a flash memory.

It is another object of the present invention to provide a flash memorybased system and management method therefor, which allow for consistentdata recovery in an emergency such as power cut-off.

It is still another object of the present invention to provide a flashmemory based system and management method therefor, which preventdegradation of system performance in an environment where data updatesto a specific page are frequently made such as a DOS file system basedon a file allocation table (FAT).

Accordingly, to achieve the above objects, the present inventionprovides a method for writing predetermined data to a flash memory. Themethod includes the steps of: (a) receiving a request to write thepredetermined data to a page to which data has been written; (b) writingthe predetermined data to a log block corresponding to a data blockcontaining the page; (c) receiving a request to write the predetermineddata to the page again; and (d) writing the predetermined data to anempty free page in the log block.

Preferably, step (b) may include the step (b11) of writing thepredetermined data to an empty free page or the steps of (b21)allocating the log block; and (b22) writing the predetermined data to anempty page at the same position as the requested page in the data block.

In another embodiment, a method for writing predetermined data to aflash memory includes the steps of: (a) receiving a request to write thepredetermined data to a page; (b) allocating a log block 1-1corresponding to a first data block containing the page; (c) writing thepredetermined data to an empty page in the log block 1-1; (d) receivinga request to write the predetermined data to the page again; and (e)writing the predetermined data to an empty free page in the log block1-1.

Preferably, step (b) comprises the steps of: (b1) performing a blockmerge to create a third data block based on a second data block and asecond log block corresponding to the second data block; and (b2)allocating a free block obtained by performing an erase operation on thesecond data block as the log block 1-1.

Preferably, step (b1) is performed when a free block to be allocated asthe log block 1-1 does not exist or when all pages of the existing logblock corresponding to the first data block have been used.

More preferably, step (b1) may include the step of (b11) performing aswitch merge to change the second log block to the third data block whenpages of the second log block are arranged in the same order that pagesof the second data block are arranged, and the pages of the second logblock correspond one-to-one to the pages of the second data block. Step(b1) may include the step of (b12) performing a copy merge to copycorresponding pages of the second data block to free pages in the secondlog block and create the third data block when the pages in the secondlog block are requested to be written only once. Step (b1) may includethe step of (13) performing a simple merge to copy the latest pages inthe second log block to free pages of a free block to which data has notbeen written and copy a corresponding page of the second data block tothe remaining free pages thereof, thereby creating the third data block.

Most preferably, step (e) includes the steps of: (e1) allocating a newlog block 1-2 if a free page does not exist in the log block 1-1; and(e2) writing the predetermined data to a free page in the log block 1-2.Step (e1) may include the steps of: (e11) performing a switch merge tochange the log block to a second data block when pages of the log block1-1 are arranged in the order in which pages of the first data block arearranged and the pages of the log block 1-1 correspond one-to-one to thepages of the first data block, and (e12) allocating a free blockobtained by performing an erase operation on the first data block as thelog block 1-2. Step (e1) may include the steps of (e21) performing acopy merge to copy corresponding pages in the first data block to a freepage in the log block 1-1 when pages in the log block 1-1 are requestedto be written only once; and (e22) allocating a free block obtained byperforming an erase operation on the first data block as the log block1-2. Step (e1) may include the steps of: (e31) performing a simple mergeto copy the latest pages in the log block 1-1 to free pages of a freeblock and copy a corresponding page of the first data block to theremaining free pages thereof, thereby creating a second data block; and(e32) allocating a free block obtained by performing an erase operationon the first data block or the log block 1-1 as the log block 1-2.

Preferably, step (e2) may include the step of (e21) writing thepredetermined data to a free page at the same position as the requestedpage in the data block.

The present invention also provides a method for reading predetermineddata from a flash memory. The method includes the steps of: (a)searching a log pointer table for an entry in which a block addressportion of a logical address of a requested page is recorded; (b)checking whether the logical address of the requested page exists in thefound entry; and (c) referring to a physical address of a correspondinglog block recorded in the found entry and a position at which thelogical address of the requested page is written to the found entry andaccessing a corresponding page of the log block. Preferably, in step(c), the corresponding page in the log block is accessed at the sameposition as the position to which the logical address of the requestedpage is written to the found entry.

The present invention also provides a method for managing a flash memoryincluding a data block and a log block for writing data for updating thedata block. The method includes the steps of (a) when pages of a firstdata block are arranged in the same order in which pages of a first logblock corresponding to the first data block are arranged and all thepages of the first data block map one-to-one with the pages of the firstlog block, changing the first log block to a second data block; and (b)updating address conversion information.

In another embodiment, a method for managing a flash memory including adata block and a log block for writing data for updating the data blocksincludes the steps of: (a) when pages in a first log block are requestedto be written only once, copying a corresponding page of a first datablock to a free page of the first log block in order to create a seconddata block; and (b) updating address conversion information.

In another embodiment, a method for managing a flash memory including adata block and a log block for writing data for updating the data blockincludes the steps of: (a) copying the latest pages in a first log blockto a free block to which data has not been written and copying acorresponding page of a first data block corresponding to the first logblock to a remaining free page to create a second data block; and (b)updating address conversion information.

Preferably, prior to step (a), the flash memory management methodfurther includes the step of (a0) writing recovery information forrecovering data in the event of a system failure during the step (a) or(b).

Preferably, the flash memory management method further includes the stepof (c) recovering data referring to the recovery information in theevent of a system failure during the step (a) or (b).

The recovery information includes a list of free blocks, a list of logblocks, and a log pointer table which is the data structure for managingthe log blocks. The log pointer table contains log pointer table entriescorresponding one-to-one to the log blocks, each entry mapping aphysical address of a log block to a logical address of a correspondingdata block and storing logical addresses of requested pages of a datablock in the order in which pages of a corresponding log block arephysically arranged.

In another embodiment, a method for managing a flash memory including adata block and a log block for writing data for updating the data blocksincludes the steps of: (a) allocating a predetermined region to a flashmemory and writing lists of data blocks and log blocks and a datastructure for managing the log blocks to the predetermined region asrecovery information; (b) checking states currently being written to theflash memory based on the recovery information in the event of a systemfailure to determine whether an error occurs; and (c) if the erroroccurs, recovering data based on the recovery information.

BRIEF DESCRIPTION OF THE DRAWINGS

The above objects and advantages of the present invention will becomemore apparent by describing in detail preferred embodiments thereof withreference to the attached drawings in which:

FIG. 1 is a block diagram of a flash memory based system according to apreferred embodiment of the present invention;

FIG. 2 is a reference diagram for explaining blocks for storing ordinarydata provided in the flash memory of FIG. 1 according to the presentinvention;

FIG. 3 is reference diagram for explaining a read operation for a logblock and a data block;

FIG. 4 is a reference diagram for explaining sections into which theflash memory of FIG. 1 is divided according to an embodiment of thepresent invention;

FIG. 5 is a reference diagram for explaining sections into which theflash memory of FIG. 1 is divided according to another embodiment of thepresent invention;

FIG. 6 is a reference diagram for explaining a log pointer table;

FIG. 7 shows the structure of an entry of a log pointer table;

FIG. 8 shows the relationship between a log pointer table and a flashmemory;

FIG. 9 is a reference diagram for explaining an erasable block;

FIG. 10 is a conceptual diagram of a simple merge;

FIG. 11 is a conceptual diagram of a copy merge;

FIG. 12 shows changes in blocks when a block merge according to thepresent invention is performed;

FIG. 13 is a flowchart of a read operation according to the presentinvention;

FIG. 14 is a flowchart of a write operation according to the presentinvention; and

FIG. 15 is a flowchart of a block merge operation.

DETAILED DESCRIPTION OF THE INVENTION

Referring to FIG. 1, a flash memory based system includes a flash memory1, a read-only memory (ROM) 2, a random access memory (RAM) 3, and aprocessor 4. In combination with program codes typically recorded in theROM 2, the processor 4 issues a series of read or write commands to readdata from and write data to the flash memory 1 or the RAM 3. Write andread operations are performed on the flash memory 1 in accordance with aflash memory management method according to the present invention. TheROM 2 and the RAM 3 store application program codes executed by theprocessor 4 or related data structures.

Referring to FIG. 2, the flash memory 1 includes a plurality of datablocks and log blocks corresponding to at least some of the plurality ofdata blocks. A data block is a block for storing any ordinary data, anda log block is a block provided for recording modified data if apredetermined part of a data block is to be modified. Thus, a pluralityof log blocks corresponding to the plurality of data blocks containmodified pages of the corresponding data blocks. Pages stored in the logblocks have priority over the counterparts stored in the correspondingdata blocks to be referred to. In this specification, the pages havingfirst priority are called “valid pages”, and pages ignored by the validpages even as physically valid data is recorded in the ignored pages arecalled “invalid pages” in a logical sense.

Referring to FIG. 3, upon a request of a user to read a predeterminedpage at a predetermined logical address, the processor 4 refers to a logpointer table recorded in the RAM 3 to check whether a log blockcorresponding to the predetermined page exists. If a corresponding logblock exists, a check is made as to whether the requested page isvalidly stored in the log block. If the requested page is validly storedin the log block, the page stored in the log block is read. If not, acorresponding page stored in the data block corresponding to the logblock is read. The log pointer table will be described below.

FIG. 4 is a reference diagram showing regions into which the flashmemory 1 is divided according to an embodiment of the present invention.Referring to FIG. 4, the flash memory 1 is divided into a map region, alog block region, a data block region, and a free block region. The mapregion stores address conversion information, the log block region isprovided for log blocks, the data block region is provided for datablocks to store ordinary data, and the free block region is provided forallocating log blocks or data blocks. Here, the flash memory 1 islogically divided to form the four regions. Thus, physically, the fourregions, in particular, the data block region, the log block region, andthe free block region could discontinuously exist in the flash memory 1in several scattered regions.

FIG. 5 is reference diagram showing regions into which the flash memory1 is divided according to another embodiment of the present invention.Referring to FIG. 5, the flash memory 1 is divided into a map region, acheck point region, a log block region, a data block region, and a freeblock region. In this embodiment, the check point region is additionallyprovided. Recovery information required for data recovery is recorded inthe check point region. Similar to the regions shown in FIG. 4, the mapregion stores address conversion information, the log block region isprovided for allocating log blocks, the data block region recordsordinary data, and the free block region is provided for allocating logblocks or data blocks. The address conversion information and therecovery information stored in the map region and the check pointregion, respectively, will be described below in detail.

The log pointer table refers to a data structure for managing logblocks. The log pointer table contains a logical address of a datablock, a physical address of a corresponding log block, and offsetvalues (a logical address of a requested page) of updated pages in thecorresponding data block arranged in the same order in which pages inthe log block are physically arranged. According to the presentinvention, the processor 4 scans a log block region to construct the logpointer table in the RAM 3. Referring to FIG. 6, the log pointer tablecontains entries corresponding to each of the log blocks. Upon receivinga request to read data from or write data to a specific location in theflash memory 1 along with a logical address of a predetermined page, theprocessor 4 refers to the log pointer table to access a log block or adata block depending on the presence of a corresponding entry.

FIG. 7 shows the structure of a log pointer table entry. Referring toFIG. 7, the log pointer table entry contains a logical address log_blkof a data block and a physical address phy_blk of a corresponding logblock. Also, the log pointer table entry records logical addresses page#0, page#1, . . . , page #N of corresponding pages in the log block inan order in which pages in the data block are recorded.

For example, assuming that a block contains sixteen pages and a logicaladdress is 02FF (hexadecimal number), the first three digits “02F”denote a block address and the last digit “F” denotes an offset value ofa requested page in a log block. Thus, a check is made as to whether 02Fexists among logical addresses log_blk stored in the logical pointertable to confirm the presence of a corresponding log block. If thecorresponding log block exists, it is checked whether the logicaladdress 02FF of the requested page or the offset value F is recorded inthe corresponding entry to locate an updated page in the log block. Forexample, if page #0 is F, the requested page is recorded in the firstphysical page in the log block.

In this way, a portion of a requested logical address, that is, a blockaddress portion thereof, is used to check whether a log block exists andaccess the block. This technique is called “block addressing”. Then, theentire logical address being requested or an offset value is used toaccess a page in the corresponding log block, which is called “pageaddressing”. Thus, the present invention adopts both block addressingand page addressing to enable the same page updated many times to berecorded in one log block.

FIG. 8 is a reference diagram showing the relationship between the logpointer table and the flash memory 1. As shown in FIG. 8, the logicaladdress log_blk of a data block is used to search for a log blockcorresponding to the data block, and then a physical address phy_blk isused to find a location to which the corresponding log block is written.Furthermore, according to the present invention, logical addresses page#0, page #1, . . . , page #15 of pages in the corresponding log blockare written to the log pointer table entry. In this embodiment, eachblock contains sixteen pages.

Basically, updated pages are written to the log block at the samepositions as those at which the corresponding pages are located in thedata block. Actually, if an updated page is first written to the logblock, the updated page may be written at the same position as thecorresponding page of the data block. However, if the updated page is tobe updated again, it is not always possible to be written at the sameposition as the corresponding page of the data block. That is, if thepredetermined page in the corresponding data block is updated once againbefore updating the remaining pages in the data block once, thepredetermined page is written to an empty space of the log block.

FIG. 9 is a reference diagram for explaining an erasable block. If allpages in a data block are updated only once, pages of a log block mapone-to-one with those of the data block. In this case, since the logblock contains all the content of the data block, data loss does notoccur even if the data block is erased. The (entirely shadowed) datablock where valid data does not exist any more is called an “erasableblock”. The erased block is called a “free block”. The erasable blockcan be erased any time, and the free block can be allocated as a datablock or a log block when necessary for the application.

Meanwhile, the present invention involves performing a block merge. Theblock merge is performed when a write operation is repeated so that apage that can be written does not exist in the log block. In this case,the log block and the corresponding data block are merged to create anew data block while erasing the previous log block to be a free block.In particular, a block merge performed when all pages in a data blockare updated only once to arrange the pages in the data block in theorder in which pages are located in the log block is called a “switchmerge”.

In contrast, if the page arrangement in a log block is not the same asthat in a corresponding data block, a simple merge is performed.Furthermore, the simple merge is performed when all pages of the logblock are currently written or read so a new log block needs to beallocated for a newly requested write operation. In this case, the logblock to be merged may have a free page.

If all the pages in a log block are updated only once, empty pages arefilled with corresponding pages of a data block to change the log blockto the data block. This is called a “copy merge”. That is to say, thereare three types of block merges; a switch merge, a simple merge, and acopy merge.

As described above with reference to FIG. 9, the switch merge isperformed by changing a log block in which all pages of a correspondingdata block are updated only once to a data block. This change is made byupdating address conversion information without copying of data thathave been written to the data block or the log block. That is, addressconversion information recorded in a map region is updated so that thecorresponding log block is mapped to a logical address requested by theuser. The map region stores address conversion information for everyblock to enable block addressing. Here, an invalid page refers to a pageignored by valid pages, and in actual implementation, the invalid pagemay be physically valid.

As shown in FIG. 10, a simple merge is performed to create a new datablock by writing valid pages of a data block and a corresponding logblock at the same positions in a new free block as the positions atwhich the valid pages were written to the data block and the log block.Thus, the merged data block and the log block can be erasable blocks.

As shown in FIG. 11, a copy merge is performed by copying valid pageswritten to the existing data block to free pages in a corresponding logblock. The existing data block is changed to an erasable block. Asdescribed, invalid pages used in the block merge are to pages notfirstly referred to, and in actual implementation, they may bephysically valid pages.

FIG. 12 shows changes in blocks as a block merge according to thepresent invention is performed. Referring to FIG. 12, a free block ischanged to a log block or a data block. A log block is changed to a datablock through a switch merge or a copy merge or to an erasable blockthrough a simple merge. A data block is changed to an erasable blockthrough a switch merge, a copy merge, or a simple merge. An erasableblock is erased to be a free block again.

To perform a block merge, lists for free blocks and erasable blocksresiding in the flash memory 1 are required. The lists for free blocksand erasable blocks refer to a data structure recorded in the RAM 3along with a log pointer table. The lists may be recorded in the mapregion and the check point region of the flash memory 1.

A list of free blocks, a list of erasable blocks, and a log pointertable must be reconstructed in the RAM 3 during a system reset. Thecheck point region is allocated according to an embodiment of thepresent invention for recording recovery information required for quickand thorough recovery of these data structures. If the check pointregion is provided, the list of free blocks, the list of erasableblocks, and the list of log blocks described above are stored in thecheck point region as recovery information. In particular, the checkpoint region also stores a plan log that lists which type of block mergeis to be performed and changes in blocks as a result of the block mergein order to prevent loss of information due to an overwhelmed system,unexpected power outage and the like, which may occur during the blockmerge. More specifically, the plan log contains the type of block mergeto be performed, and physical addresses of a block changed from a freeblock to a data block, of a block changed from a data block to a freeblock, and of a block changed from a log block to a free block.

Furthermore, the check point region stores information necessary forconstruction of the address conversion information such as a locationwhere address conversion information is stored. The location of thecheck point region itself is recorded in a predefined block in the flashmemory 1.

Based on the above configurations, a method for flash memory managementaccording to a preferred embodiment of the present invention will now bedescribed. For ease of understanding, the flash memory management methodis divided into a method of constructing and reconstructing a datastructure upon a system startup, a method for reading data from theflash memory 1, and a method for writing data to the flash memory 1.

First, a flash memory management method used during a system startupmeans a method for constructing or reconstructing a data structure. Thatis, the method involves constructing address conversion information aswell as data structures including a list of free blocks, a list oferasable blocks, a list of log blocks, and a log pointer table for writeand read operations, and examining the integrity of the constructedinformation to reconstruct the data structures based on recoveryinformation if reconstruction is needed. When the system of FIG. 1 isinitialized, the processor 4 must construct the log pointer table andthe lists of free blocks, erasable blocks and log blocks. To accomplishthis, the processor 4 reads recovery information from most recentlywritten pages stored in the check point region of the flash memory 1.This is because, if the recovery information is sequentially written,most recent recovery information is written to a page locatedimmediately before a free page (empty page) firstly found in the checkpoint region. However, the order in which the recovery information iswritten may be changed when necessary for the application as long as itis possible to identify the most recently written page.

The log pointer table is constructed by scanning all pages of each logblock designated in the recovery information to read a logical addressstored in a logical block address portion for each page. Since the mapregion also sequentially stores address conversion information, a lastlywritten page (the page immediately before a first free page) isconsidered to be changed most recently, and address conversioninformation can be constructed based on the lastly written page. Thefree block list and the erasable block list can also be readilyreconstructed based on the recovery information.

Next, the constructed information including the log pointer table andthe lists of free blocks, erasable blocks and log blocks is verified byreferring to a plan log. That is, it should be verified whether theconstructed information is the same as real conditions when theoperation of the system is stopped during a block merge. Morespecifically, if the system ceases to operate upon writing recoveryinformation to the check point region, upon performing a block merge,upon updating address conversion information in the map region, and uponperforming an erase operation, verification is needed. For each case, itis checked whether the constructed information is consistent with realconditions, and if not, the constructed information is reconstructed asfollows:

1. When the system ceases to operate upon writing recovery informationto the check point region, a first free page from the recoveryinformation written in the check point region is located to checkwhether the found page is actually an empty page by reading data storedtherein. If the free page is not empty, it is determined that the systemceased to operate while writing recovery information to the check pointregion. Since this occurs before actually writing data, it is notnecessary to perform a recovery procedure, and finally recorded recoveryinformation is ignored.

2. When the system ceases to operate during a block merge, it is checkedwhether data has been properly written to all pages of a block listed inthe plan log as a block to be changed to a data block. If a page, ifany, is not valid, it is determined that the system ceased to operateduring a block merge. In this case, a block merge is performed again torecover data appropriately.

3. When the system ceases to operate while updating address conversioninformation, a logical address is read from a block listed in the planlog as a block to be changed to a data block to check whether thelogical address is consistent with the information stored in the mapregion. If not, it can be determined that the system ceased to operatewhile updating the address conversion information. In this case, datacan be appropriately recovered by modifying the address conversioninformation based on the logical address read from the data block and acorresponding physical address.

4. When the system ceases to operate during an erase operation, it ischecked whether blocks listed in the plan log as a block to be changedto a free block are actually empty blocks. If a block is a not freeblock (if all pages in the block are not empty), an erase operation isperformed on the written block again.

When required data structures are constructed and then integrityverification is completed in the manner previously described through aflash memory management method used upon system startup, read and writeoperations can be performed.

FIG. 13, is a flowchart of a read operation according to the presentinvention. The processor 4 searches for a log block in which a pagebeing requested exists, and reads the requested page from the found logblock. More specifically, the processor 4 sequentially searches a logpointer table for an entry corresponding to a logical address of arequested page (step 1301). Since the logical address of the requestedpage consists of a block addressing portion and a page addressingportion, an entry is searched for by referring to the block addressingportion. If a matched entry is found (step 1302), it is checked whetherthe requested page exists in the found entry (step 1303). If therequested page is found, the page is read (step 1305). In this case, iftwo or more identical pages are found, a lastly found page among thoseexcept for one existing at the position of the same offset value isdetermined to be the latest one, and that page is read. If a match isnot found in the step 1302, or if the requested page does not exist in alog block (step 1304), a corresponding page of a data block is readbased on the requested logical address (step 1306).

FIG. 14 is a flowchart of a write operation according to the presentinvention. The processor 4 firstly searches for a log block in which apage being requested exists. If the log block is found, it checkswhether a page in the log block at the same position as the requestedpage is usable. If the corresponding page is usable, writing isperformed on the page. If it is not usable, writing is performed onanother page that is usable in the log block. If a usable page does notexist in the log block, a new log block is allocated to perform writingat the same position.

More specifically, the processor 4 searches a log pointer table for anentry based on a logical address of a page being requested (step 1401).If the entry is found (step 1402), which means that a log blockcorresponding to the logical address exists, an entry is searched tocheck whether a page having the same offset value as the requested pageis usable (step 1403). If the page is usable, a write operation isperformed on the corresponding page (step 1404). Here, the usable pagerefers to an empty page (free page) that has not been written to. Thepresence of a free page can be determined by whether a page is valid(the page is firstly referred to or data is written to the page). Next,a physical address of the page on which the write operation has beenperformed corresponding to the logical address is written to thecorresponding entry of the log pointer table. In this case, the writerequest by the user is completed by one write operation in the flashmemory 1.

If the corresponding log block is found, but the page having the sameoffset has been used (step 1403), it is checked whether another freepage in the log block can be allocated (step 1406), and a writeoperation is performed on the allocated free page (step 1407). If two ormore free pages exist, the log block is sequentially searched from thestart to allocate a page closest to the page corresponding to therequested page to which data have been already written. Then, a physicaladdress of the allocated page corresponding to the logical address ofthe requested page is written to the corresponding entry of the logpointer table (step 1405).

If an entry corresponding to the requested page is not found as a resultof searching the log pointer table, it is checked whether a new logblock can be allocated (step 1408). If free blocks to be allocated asthe new log block exist, one of the free blocks is allocated as the newlog block (step 1408). If a free block does not exist, the free block iscreated by performing a block merge and then allocated as the new logblock (step 1409). A write operation is performed on a page in theallocated log block having the same offset value as the requested page(step 1410). Then, a corresponding entry is created in the log pointertable (step 1405).

FIG. 15 is a flowchart of a block merge operation. Referring to FIG. 15,a block merge is performed in different ways depending on thearrangement of pages in a log block. More specifically, the processor 4checks whether all pages of a log block are located at the samepositions as those of a corresponding data block (step 1501). If so, itis next checked whether all the pages of the log block are valid (step1502). If all pages in the log block are arranged in the same order inwhich those of the data block are arranged and they are valid, a switchmerge is performed. Before performing a switch merge, the processor 4writes recovery information to the check point region (step 1503). Thestep 1503 may be omitted according to the choice of a system designer.To perform a switch merge, the processor 4 updates address conversioninformation stored in the map region so that the log block is a new datablock (step 1504). That is, if the log block is changed to the new datablock, since a physical address corresponding to the logical address ischanged in view of the user, the address conversion information must beupdated. Actually, the updated address conversion information can bewritten to a first free page in the map region. Similarly, the mapregion sequentially stores the address conversion information, and if afree page does not exist, a free block is allocated for the map regionto write the information to the allocated free block. The allocation ofa free block is made in the same manner as described with reference toFIG. 14. Then, the data block is changed to an erasable block, the datablock is erased, and a free block list recorded in the check pointregion is updated (step 1505).

If any pages in the log block are not arranged at the same position as acorresponding page of the data block, a simple merge is performed.Similarly, the processor 4 writes recovery information to the checkpoint region before performing a simple merge (step 1506). The step 1506may be omitted according to the choice of the system designer. Then,free blocks are allocated to copy valid pages of the log block to someof the free blocks (step 1507). Corresponding pages of the data blockare copied to the remaining free blocks (step 1508). Address conversioninformation in the map region is updated so that the free blocks are newdata blocks (step 1509). The allocation of free blocks is made in themanner described with reference to FIG. 14. The log block and the datablock are changed to an erasable block, the log block and the data blockare erased, and a free block list recorded in the check point region isupdated (step 1510).

If all pages of the log block are arranged in the same manner in whichthose of the data block are arranged but some of the pages in the datablock do not exist in the log block, a copy merge is performed.Similarly, the processor 4 writes recovery information to the checkpoint region before performing a copy merge (step 1511).

The step 1511 may be omitted according to the choice of the systemdesigner. Then, valid pages of the data block are read to copy them tothe log block (step 1512). Address conversion information stored in themap region is updated so that the log block is a new data block (step1504), and then the data block is erased and a free block list stored inthe check point region is updated (step 1505).

In this way, if the log block for updating data is not found, a freeblock is allocated, the free block is changed to a log block, andwriting to the log block is performed. If only one free block remains soit is not allocated as a log block, one of the existing log blocks isarbitrarily selected to perform a block merge, thereby creating a newfree block. Then, the free block is allocated as a log block. In thisinvention, costs required for a block merge and usability of blocksshould be appropriately considered. The usability of blocks may varydepending on the type of application program to be executed. Replacementalgorithms may not be specified in this invention. Thus, the presentinvention may be implemented using common replacement algorithms such asleast recently used (LRU).

As described above, the present invention provides a method for flashmemory management for improving the performance of a flash memory.Conventionally, in order to update a part of one data block, theremaining parts are also copied or a large amount of address conversioninformation is needed. However, the present invention allows the samepage to be continuously updated within one log block, thereby improvingthe effectiveness of flash memory resources. Furthermore, the presentinvention allows data to be recovered consistently in the event that asystem malfunctions due to power outage during a block merge.

What is claimed is:
 1. A method for writing predetermined data to aflash memory, the method comprising the steps of: (a) receiving arequest to write the predetermined data to a page to which data has beenwritten; (b) writing the predetermined data to a log block correspondingto a data block containing the page; (c) receiving a request to writethe predetermined data to the page again; and (d) writing thepredetermined data to an empty free page in the log block.
 2. The methodof claim 1, wherein the step (b) comprises the step (b11) of writing thepredetermined data to an empty free page.
 3. The method of claim 1,wherein the step (b) comprises the steps of: (b21) allocating the logblock; and (b22) writing the predetermined data to an empty page at thesame position as the requested page in the data block.
 4. The method ofclaim 1, wherein the data block is configured to store data and the logblock is configured to store data which has been modified.
 5. A methodfor writing predetermined data to a flash memory, the method comprisingthe steps of: (a) receiving a request to write the predetermined data toa page; (b) allocating a log block 1-1 corresponding to a first datablock containing the page; (c) writing the predetermined data to anempty page in the log block 1-1; (d) receiving a request to write thepredetermined data to the page again; and (e) writing the predetermineddata to an empty free page in the log block 1-1.
 6. The method of claim5, wherein the step (b) comprises the steps of: (b1) performing a blockmerge to create a third data block based on a second data block and asecond log block corresponding to the second data block; and (2)allocating a free block obtained by performing an erase operation on thesecond data block as the log block 1-1.
 7. The method of claim 6,wherein the step (b1) is performed when a free block to be allocated asthe log block 1-1 does not exist.
 8. The method of claim 6, wherein thestep (b1) is performed when all pages of the existing log blockcorresponding to the first data block have been used.
 9. The method ofclaim 6, wherein the step (b1) comprises the step of (b11) performing aswitch merge to change the second log block to the third data block whenpages of the second log block are arranged in the same order that pagesof the second data block are arranged, and the pages of the second logblock correspond one-to-one to the pages of the second data block. 10.The method of claim 6, wherein the step (b1) comprises the step of (b12)performing a copy merge to copy corresponding pages of the second datablock to free pages in the second log block and create the third datablock when the pages in the second log block are requested to be writtenonly once.
 11. The method of claim 6, wherein the step (b1) comprisesthe step of (13) performing a simple merge to copy the latest pages inthe second log block to free pages of a free block to which data has notbeen written and copy a corresponding page of the second data block tothe remaining free pages thereof, thereby creating the third data block.12. The method of claim 5, wherein the step (e) comprises the steps of:(e1) allocating a new log block 1-2 if a free page does not exist in thelog block 1-1 and (e2) writing the predetermined data to a free page inthe log block 1-2.
 13. The method of claim 12, wherein the step (e1)comprises the steps of: (e11) performing a switch merge to change thelog block to a second data block when pages of the log block 1-1 arearranged in the order in which 5 pages of the first data block arearranged and the pages of the log block 1-1 correspond one-to-one to thepages of the first data block, and (e12) allocating a free blockobtained by performing an erase operation on the first data block as thelog block 1-2.
 14. The method of claim 12, wherein the step (e1)comprises the steps of: (e21) performing a copy merge to copycorresponding pages in the first data block to a free page in the logblock 1-1 when pages in the log block 1-1 are requested to be writtenonly once; and (e22) allocating a free block obtained by performing anerase operation on the first data block as the log block 1-2.
 15. Themethod of claim 12, wherein the step (e1) comprises the steps of: (e31)performing a simple merge to copy the latest pages in the log block 1-1to free pages of a free block and copy a corresponding page of the firstdata block to the remaining free pages thereof, thereby creating asecond data block; and (e32) allocating a free block obtained byperforming an erase operation on the first data block or the log block1-1 as the log block 1-2.
 16. The method of claim 12, wherein the step(e2) comprises the step of (e21) writing the predetermined data to afree page at the same position as the requested page in the data block.17. The method of claim 5, wherein the first data block is configured tostore data and the log block 1-1 is configured to store data which hasbeen modified.
 18. A method of writing data to a flash memory, the flashmemory organized into a plurality of blocks, each block comprising aplurality of pages, the method comprising: in a state where data hasbeen previously written to a page of a data block, receiving a logicaladdress of the page of the data block, the logical address comprising ablock address portion and a page identifying portion; determining afirst physical block address of a first log block associated with thedata block by referencing a block address table, the block address tableassociating block address portions of logical addresses of data blockswith respective physical block addresses of log blocks; writing data toa first page of the first log block associated with the data block,wherein the location of the first page within the first log block isselected, in response to the page identifying portion of the logicaladdress, to correspond to a location of the page of the data block;updating a page address record to associate the first page of the logblock to at least the identifying portion of the logical address; andafter the writing data to the first page of the log block, writing datato an empty free page of the first log block in response to receiving awrite command associated with the page of the data block.
 19. The methodof claim 18, wherein the page identifying portion of the logical addressis an offset value, and wherein the location of the first page withinthe first log block is at a location within the first log block that isthe same as the location indicated by the offset value.
 20. The methodof claim 18, wherein the page address record is associated with thefirst physical block address in the block address table.
 21. The methodof claim 20, wherein the page address record and block address table arestored in a random access memory.
 22. The method of claim 18, furthercomprising updating the page address record to associate the second pageof the log block to at least the page identifying portion of the logicaladdress.
 23. The method of claim 22, wherein the location of the secondpage is a page closest to the first page.
 24. The method of claim 18,further comprising, before writing data to the first page: receiving thelogical address of the page of the data block; and reading data from apage of the data block associated with the logical address.
 25. Themethod of claim 18, further comprising: merging data of the data blockand the first log block by writing data of some of the pages of the datablock to pages of the first log block, pages of the first log block towhich data is written having a same relative location within the firstlog block as the relative location of a respective page within the datablock from which corresponding data was written.
 26. A flash memorycontroller comprising: a processor; and a memory storing program codescontaining instructions that when executed cause the processor toimplement the method of claim
 18. 27. A flash memory system, comprising:a flash memory; and the flash memory controller of claim
 26. 28. Amethod of writing data to a flash memory, the flash memory organizedinto a plurality of blocks, each block comprising a plurality of pages,the method comprising: in a state where data has been previously writtento a page of a data block, receiving a logical address of the page ofthe data block, the logical address comprising a block address portionand a page identifying portion; determining whether a log block has beenassociated with the data block by referencing a block table associatinglogical addresses of data blocks with respective ones of physicaladdresses of log blocks; when no log block is found to be associatedwith the data block, allocating a free block as the log block associatedto the data block; writing data to a first page of the log blockassociated with the data block, wherein the location of the first pagewithin the first log block is selected, in response to the pageidentifying portion of the logical address, to correspond to a locationof the page of the data block; updating a page address record toassociate the first page of the log block to at least the pageidentifying portion of the logical address; and after the writing datato the first page of the log block, writing data to an empty free pageof the first log block in response to receiving a write commandassociated with the page of the data block.
 29. The method of claim 28,wherein the block table and page address record are part of a datastructure, the page address record being associated with the log blockwithin the data structure.
 30. The method of claim 28, wherein the blocktable and page address record are stored in RAM.
 31. The method of claim28, wherein the page identifying portion of the logical address is anoffset value identifying an address offset from the block addressportion of the logical address.
 32. The method of claim 31, wherein thestep of updating the page address record includes storing the offsetvalue at a location in the page address record corresponding to thelocation of the first page within the log block.
 33. The method of claim31, wherein the step of updating the page address record includesstoring the entire logical address including the offset value at alocation in the page address record corresponding to the location of thefirst page within the log block.
 34. The method of claim 28, furthercomprising updating the page address record to associate the second pageof the log block to at least the page identifying portion of the logicaladdress.
 35. The method of claim 28, further comprising, before writingdata to the first page: receiving the logical address of the page of thedata block; and reading data from a page of the data block associatedwith the logical address.
 36. The method of claim 28, furthercomprising: merging valid data of the data block and the first log blockby writing valid data of some of the pages of the data block to emptypages of the first log block, pages of the first log block to whichvalid data is written having a same relative location within the firstlog block as the relative location of a respective page within the datablock from which corresponding data was written.
 37. The method of claim36, further comprising, after merging data of the data block and thefirst log block, erasing the data block.